package com.xuecheng.content.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xuecheng.content.mapper.CourseAuditMapper;
import com.xuecheng.content.mapper.CourseBaseMapper;
import com.xuecheng.content.model.po.CourseAudit;
import com.xuecheng.content.service.CourseAuditService;
import com.xuecheng.content.service.CoursePublishPreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Slf4j
@Service
public class CourseAuditServiceImpl extends ServiceImpl<CourseAuditMapper, CourseAudit> implements CourseAuditService {

    @Autowired
    CoursePublishPreService coursePublishPreService;


    /**
     * 提交课程审核
     * @param courseId
     */
    @Override
    @Transactional
    public void commitForAudit(Long courseId) {
        //1.修改审核表
        CourseAudit courseAudit = new CourseAudit();
        courseAudit.setCourseId(courseId);
        //设置为审核状态
        courseAudit.setAuditStatus("002002");
        save(courseAudit);
        //添加到预发布表
        coursePublishPreService.saveCourse(courseId);
    }
}
